#!/bin/csh -f

set INST_DIR=charybda

set TID="$TMPFILEDIR/charybda"
if ( -w $TID ) then
	set  INST_PATH=$TID
else
	LOOP1:
	echo " "
	echo "Enter the name of the directory where Charybda "
	echo "is installed ( q to quit ) :  \c"
	set INST_PATH = $<

	if ($#INST_PATH == 0 ) then
		echo " "
		echo "Input Error.  Please try again."
		goto LOOP1
	else if ( $INST_PATH == 'q' ) then
		echo " "
		echo ... Bye"
		sleep 3
		exit
	endif
	if ( ! -d $INST_PATH ) then
		echo " "
		echo "Can't find the $INST_PATH directory."
		echo " "
		echo "Press Enter to quit, and then try again.  \c"
		set a = $<
		\rm -f $TMPFILEDIR$INST_DIR > /dev/null
		exit -1
	endif
endif

echo " "
echo "About to remove the entire $INST_PATH directory."
LOOP2:
echo " "
echo "Continue (y/n)?  \c"
set a = $<
if ( $a == 'n' ) then
	exit -1
else if ( $a == 'y' ) then
else
	goto LOOP2
endif

if ( -w $INST_PATH ) then
	\rm -rf $INST_PATH
else
	echo " "
	echo "You have no permission to remove the $INST_PATH directory"
	echo " "
	su - root -c "/bin/rm -rf $INST_PATH"
endif
\rm -f $TMPFILEDIR$INST_DIR > /dev/null

echo " "
echo "Removal Complete\!"
echo " "
echo "Press Enter to exit this window...  \c"
set a = $<

